package com.zx.erp.repo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zx.erp.repo.bean.KcWarehouse;
import com.zx.erp.repo.mapper.KcWarehouseDao;
import com.zx.erp.repo.service.KcWarehouseBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KcWarehouseBizImpl implements KcWarehouseBiz {
    @Autowired
    private KcWarehouseDao kcWarehouseDao;


    @Override
    public PageInfo<KcWarehouse> findAllKc(String cname, String brandNmae, String typeName, String proName, Integer pageno, Integer pagesize) {
        PageHelper.startPage(pageno, pagesize);
        List<KcWarehouse> allKc = kcWarehouseDao.findAllKc(cname, brandNmae, typeName, proName);
        PageInfo<KcWarehouse> pin = new PageInfo<>(allKc);
        return pin;
    }

    @Override
    public Boolean saveKc(KcWarehouse kcWarehouse) {
        return kcWarehouseDao.addKC(kcWarehouse);
    }


    @Override
    public PageInfo<KcWarehouse> findAllByLike(String cName, String brandName, String typeName, String productModel, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<KcWarehouse> allByLike = kcWarehouseDao.findAllByLike(cName, brandName, typeName, productModel);
        PageInfo<KcWarehouse> kcWarehousePageInfo = new PageInfo<>(allByLike);
        return kcWarehousePageInfo;
    }

    @Override
    public Boolean deleteKc(KcWarehouse kcWarehouse) {

        return kcWarehouseDao.deleteKc(kcWarehouse);
    }

    @Override
    public boolean updateKCW(KcWarehouse kcw) {
        return kcWarehouseDao.updateKCw(kcw);
    }

    @Override
    public List<KcWarehouse> findBy5c(KcWarehouse kcw) {
        return kcWarehouseDao.selectBy5c(kcw);
    }

    @Override
    public KcWarehouse findBy(KcWarehouse kcw) {
        return kcWarehouseDao.selectBy(kcw);
    }

    @Override
    public boolean updateKCW2(Integer id, Integer num,Integer flag) {
        return kcWarehouseDao.updateKCW2(id, num,flag);
    }
}

